翻訳と辞書
Words near each other
・ Loose Cannons (2010 film)
・ Loose Change
・ Loose Change (book)
・ Loose Change (film series)
・ Loose chippings
・ Loose Connections
・ Loose connective tissue
・ Loose coupling
・ Loose coupling (disambiguation)
・ Loose Creek
・ Loop heat pipe
・ Loop I Bubble
・ Loop Independent School District
・ Loop integral
・ Loop interchange
Loop invariant
・ Loop inversion
・ Loop jump
・ Loop knitting
・ Loop line
・ Loop line (railway)
・ Loop Live
・ Loop Loop, Washington
・ Loop Maintenance Operations System
・ Loop Management System
・ Loop mark
・ Loop Mobile
・ Loop modeling
・ Loop nest optimization
・ Loop of Henle


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Loop invariant : ウィキペディア英語版
Loop invariant
In computer science, a loop is a programming language statement that allows code to be repeatedly executed; an invariant of a loop is a property that holds before (and after) each repetition. It is a logical assertion, sometimes programmed as an assertion. Knowing its invariant(s) is essential for understanding the effect of a loop.
In formal program verification, in particular in the Floyd-Hoare approach, loop invariants are expressed in formal predicate logic and used to prove properties of loops and, by extension, algorithms employing loops (usually correctness properties).
A loop invariant should be true on entry into a loop and is guaranteed to remain true after every iteration of the loop. This means that on exit from the loop both the loop invariant and the loop termination condition can be guaranteed.
Because of the fundamental similarity of loops and recursive programs, proving partial correctness of loops with invariants is very similar to proving correctness of recursive programs via induction. In fact, the loop invariant is often the inductive property- the induction hypothesis- one has to prove of a recursive program that is equivalent to a given loop.
==Informal example==
The following C subroutine max() returns the maximum value of its argument array a)

Following a defensive programming paradigm, the loop condition i!=n in line 5 should better be modified to i, in order to avoid endless looping for illegitimate negative values of n. While this change in code intuitively shouldn't make a difference, the reasoning leading to its correctness becomes somewhat more complicated, since then only i>=n is known in line 13. In order to obtain that also i<=n holds, that condition has to be included into the loop invariant. It is easy to see that i<=n, too, is an invariant of the loop, since i in line 6 can be obtained from the (modified) loop condition in line 5, and hence i<=n holds in line 11 after i has been incremented in line 10. However, when loop invariants have to be manually provided for formal program verification, such intuitively too obvious properties like i<=n are often overlooked.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Loop invariant」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.